#include "symbolicVariable.h"
#include <sstream>
#include <stdio.h>
#include <iostream>


std::string SymbolicVariable::toString(bool showType)
{
	std::stringstream ss;//create a stringstream
	ss << rowIndex;//add number to the streamp
	std::string typeStr;
	if(type.type == INTEGER) typeStr = "INTEGER";
	else if(type.type == STRING){
		typeStr = "STRING(";
		typeStr += type.size;
		typeStr +=")";
	}
	else if(type.type == BOOLEAN) typeStr = "BOOLEAN";
	else std::cerr<<"WARNING: Type not considered in SimbolicVariable string representation\n";

	if (showType) return tableName+"."+columnName+"."+ss.str()+"[type:"+typeStr+"]";
	else return tableName+"."+columnName+"."+ss.str();
}

std::string SymbolicVariable::toString()
{
	std::stringstream ss;//create a stringstream
	ss << rowIndex;//add number to the streamp
	return tableName+"."+columnName+"."+ss.str();
}

SymbolicVariable::SymbolicVariable(std::string tableName, std::string columnName, int rowIndex, ColumnType type, int length)
{
	this->tableName=tableName;
	this->columnName=columnName;
	this->rowIndex=rowIndex;
	this->type.type=type;
	this->type.size=length;
}


SymbolicVariable::SymbolicVariable(std::string tableName, std::string columnName, int rowIndex, TableColumnType type)
{
	this->tableName=tableName;
	this->columnName=columnName;
	this->rowIndex=rowIndex;
	this->type=type;
}

SymbolicVariable::SymbolicVariable(const SymbolicVariable & other)
{
    tableName = other.tableName;
    columnName = other.columnName;
    rowIndex = other.rowIndex;
    type = other.type;
}

SymbolicVariable::~SymbolicVariable()
{

}

Expression * SymbolicVariable::clone()
{
    return new SymbolicVariable(*this);
}
